/*
* SIP XML Scenario Maker
* Copyright 2008 Rachid El Khayari
*
* This file is part of SIP XML Scenario Maker (SXSM).
*
* SXSM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SXSM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SXSM.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

//include inherited class QMainWindow
#include <QMainWindow>

/*!
* Because used Qt classes are not needed in the interface of this class and only in the implementation,
* forward declaration of the classes in the header file is used 
* and the header files are included in the .cpp file, which speeds up compilation.
*/

class QNetworkInterface;
class QHostAddress;
class QAssistantClient;
class QAction;
class QMenu;
class QDialog;
class QGridLayout;
class QLineEdit;
class QPushButton;
class QLabel;
class QStringList;
class QSettings;
class QComboBox;
class QTextEdit;
class QSpinBox;
class QListWidget;
class QProcess;
class QProgressBar;
class QPixmap;
class QSplashScreen;
class QRadioButton;
class QTableWidget;

class MainWindow : public QMainWindow
{
	Q_OBJECT

	public:
		MainWindow();

	private slots:
/*!
 * \brief This slot initiates the creation of the settings dialog.
 */
		void settings();
/*!
 * \brief This slot initiates the creation of the message maker dialog.
 */
		void messages();
/*!
 * \brief This slot initiates the creation of the shoot mode dialog.
 */
		void shootMode();
/*!
 * \brief This slot saves changes to application settings.
 */
		void saveSettings();
/*!
 * \brief This slot initiates loading of message type list
 * in message editor mode.
 */
		void viewMessageTypeList();
/*!
 * \brief This slot initiates loading of message list
 * in message editor mode.
 */
		void viewMessageList();
/*!
 * \brief This slot initiates loading of a single message
 * in message editor mode.
 */
		void viewMessage();
/*!
 * \brief This slot initiates saving of changes to a message
 * in message editor mode.
 */
		void saveMessage();
/*!
 * \brief This slot initiates the creation of a new message set
 * in message editor mode.
 */
		void makeSet();
/*!
 * \brief This slot initiates the creation of a new message type
 * in message editor mode.
 */
		void makeType();
/*!
 * \brief This slot initiates the creation of a new message
 * in message editor mode.
 */
		void makeMessage();
/*!
 * \brief This slot adds a scenario to the shoot list
 * in shoot mode.
 */
		void addScenario();
/*!
 * \brief This slot initiates the loading of existing scenarios to the scenario list
 * in shoot mode.
 */
		void loadScenarios();
/*!
 * \brief This slot starts the shoot process
 * in shoot mode.
 */
		void scenarioShoot();
/*!
 * \brief This slot clears the shoot list
 * in shoot mode.
 */
		void resetList();
/*!
 * \brief This slot displays information about sxsm application.
 */
		void about();
/*!
 * \brief This slot displays information about Qt
 */
		void aboutQt();
/*!
 * \brief This slot prints out error messages at the end of a shoot process
 * in shoot mode.
 */
		void printError();
/*!
 * \brief This slot prints out status messages at the end of a shoot process
 * in shoot mode.
 */
		void printOutput();
/*!
 * \brief This slot prints out status messages during the execution of a shoot process
 * in shoot mode.
 */
		void printRunningOutput();
/*!
 * \brief This slot kills a running shoot process
 * in shoot mode.
 */
		void stopProcess();
/*!
 * \brief This slot controls the behaviour of radio buttons
 * in shoot mode.
 */
		void reactToUsernameRadios();
/*!
 * \brief This slot starts a dialog for creating csv files
 * in shoot mode.
 */
		void makeCSVDialog();
/*!
 * \brief This slot initiates saving of a new csv file
 * in shoot mode.
 */
		void makeCSV();
/*!
 * \brief This slot creates and opens the application's assistant.
 */
		void assistant();
/*!
 * \brief This slot loads log files.
 */
		void loadLogs();

	protected:
/*!
 * \brief This method makes sure that the application is closed properly.
 */
		void closeEvent(QCloseEvent *event);

	private:
/*!
 * \brief Creates application's actions.
 */
		void createActions();
/*!
 * \brief Creates all menus.
 */
		void createMenus();
/*!
 * \brief Initializes the application's assistant
 */
		void initializeAssistant();
/*!
 * \brief Starts the process dialog.
 */
		void makeProcessDialog();
/*!
 * \brief Starts a single process with specified nr.
 */
		void startProcess(int processnr);
/*!
 * \brief Displays a dialog for creating new sets, types and messages
 * in message editor mode.
 */
		void makeCreateDialog(int classifier);
/*!
 * \brief Writes down log files of a terminated process
 * in shoot mode.
 */
		bool writeLogs();
/*!
 * \brief Loads the message list in message editor mode.
 */
		bool loadMessagesList();
/*!
 * \brief Loads the message type list in message editor mode.
 */
		bool loadMessageTypeList();
/*!
 * \brief Loads the message set list in message editor mode.
 */
		bool loadMessageSetList();
/*!
 * \brief Creates a new set with specified name
 *  in message editor mode.
 */
		bool createSet(QString dirname);
/*!
 * \brief Creates a new type with specified name
 *  in message editor mode.
 */
		bool createType(QString dirname);
/*!
 * \brief Creates a new message with specified name
 *  in message editor mode.
 */
		bool createMessage(QString filename);
/*!
 * \brief Loads and displays messagedetails of a selected message
 *  in message editor mode.
 */
		bool loadMessagesHeaders(QString messageName);
/*!
 * \brief Writes down changes to a message permanently
 *  in message editor mode.
 */
		bool writeMessagesHeaders(QString messageName);
/*!
 * \brief Loads entries of scenario list
 *  in shoot mode.
 */
		bool loadScenarioList();
/*!
 * \brief Loads entries of scenario set list
 *  in shoot mode.
 */
		bool loadScenarioSetList();
/*!
 * \brief Loads csv list in shoot mode.
 */
		bool loadCSVList();
/*!
 * \brief writes down changes to csv files in shoot mode.
 */
		bool writeCSV(QString csvname);

/*!
 * \brief Loads and displays log files of finished processes
 *  in shoot mode.
 */
		bool loadLogFile(QString logName);

		QString DataDir;
		QString MessageDir;
		QString ScenarioDir;
		QString SIPpPath;
		QString CSVDir;
		QString LogDir;
		int shootSuccessRate;
		QAssistantClient *assistantClient;
		QProcess *myProcess;
		QMenu *fileMenu;
		QMenu *helpMenu;
		QAction *exitAct;
		QAction *messagesAct;
		QAction *settingsAct;
		QAction *shootModeAct;
		QAction *aboutAct;
		QAction *aboutQtAct;
		QAction *assistantAct;
		QDialog *shootDialog;
		QDialog *settingsDialog;
		QDialog *messagesDialog;
		QDialog *createDialog;
		QDialog *processDialog;
		QDialog *csvDialog;
		QGridLayout *settingsLayout;
		QLineEdit *sippPath;
		QLineEdit *scenarioPath;
		QLineEdit *dataPath;
		QLineEdit *messagePath;
		QLineEdit *csvPath;
		QLineEdit *logPath;
		QLabel *messagePathLabel;
		QLabel *sippPathLabel;
		QLabel *scenarioPathLabel;
		QLabel *dataPathLabel;
		QLabel *csvPathLabel;
		QLabel *logPathLabel;
		QPushButton *settingsSaveButton;
		
		QComboBox *messageSetSelect;
		QComboBox *messageTypeTemplateSelect;
		QComboBox *messageTemplateSelect;
		QLabel *messageTypeTemplateLabel;
		QLabel *messageTemplateStandardLabel;
		QLineEdit *newMessageSetLine;
		QLineEdit *newMessageTypeLine;
		QLineEdit *newMessageTemplateLine;
		QPushButton *newMessageSetButton;
		QPushButton *newMessageTypeButton;
		QPushButton *newMessageTemplateButton;
		QTextEdit *headerFields;
		QPushButton *messageSaveButton;
		
		QComboBox *shootScenarioSetSelect;
		QComboBox *shootScenarioSelect;
		QLabel *shootTimeLabel1;
		QLabel *shootTimeLabel2;
		QLabel *shootTimeLabel3;
		QLabel *shootTimeLabel4;
		QSpinBox *shootNumberOfRounds;
		QSpinBox *shootNumberOfCallsPerPeriod;
		QSpinBox *shootPeriod;
		QLabel *shootAdditionalParametersLabel;
		QLineEdit *shootAdditionalParameters;
		QPushButton *shootScenarioAdd;
		QListWidget *shootListWidget;
		QListWidget *shootNumberParameter;
		QListWidget *shootCallsPerPeriodParam;
		QListWidget *shootPeriodParam;
		QListWidget *shootAddiParam;
		QTableWidget *shootTable;
		QTextEdit *shootErrorMessages;
		QTextEdit *shootDefaultMessages;
		QPushButton *processStop;
		QPushButton *openLog;
		QLabel *scenarioParameterTargetLabel;
		QLabel *scenarioParameterRemoteIpLabel;
		QLineEdit *scenarioParameterRemoteIpLine;
		QLabel *scenarioParameterRemotePortLabel;
		QLineEdit *scenarioParameterRemotePortLine;
		QRadioButton *staticLocalUser;
		QRadioButton *csvLocalUser;
		QLineEdit *staticLocalUserLine;
		QComboBox *csvLocalUserCombo;

		QLabel *scenarioParameterLocalIpLabel;
		QComboBox *scenarioParameterLocalIpCombo;
		QLabel *scenarioParameterLocalPortLabel;
		QLineEdit *scenarioParameterLocalPortLine;

		QLabel *scenarioParameterTransportLabel;
		QComboBox *scenarioParameterTransportCombo;
		QPushButton *startShootButton;
		QProgressBar *shootProgress;
		QPushButton *shootListReset;
		QSplashScreen *splash;
		int processCounter;
		int numberOfScenarios;
		int killstatus;

		QLineEdit *newCSVNameLine;
		QTextEdit *newCSVText;
		QPushButton *newCSVButton;

		QDialog *logDialog;
		QTextEdit *logText;

};

#endif 
